package com.dfiov.cloud.msmtools.controller.msbluetooth;

import com.alibaba.fastjson.JSON;
import com.dfiov.cloud.msmtools.entity.vo.msbluetooth.VinBluetoothsVo;
import com.dfiov.cloud.msmtools.service.business.MsBluetoothService;
import com.pateo.qingcloud.framework.common.base.BaseRestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/msbluetooth")
@Api(description = "蓝牙钥匙相关")
@Slf4j
public class MsBluetoothController {
    @Autowired
    MsBluetoothService msBluetoothService;

    @GetMapping("/getBluetoothByVin")
    @ApiOperation(value = "根据vin查询车辆信息/车主信息/蓝牙钥匙", httpMethod = "GET", response = BaseRestResponse.class)
    public BaseRestResponse<VinBluetoothsVo> getBluetoothByVin(@ApiParam(value = "车架号", required = true) @RequestParam String vin) {
        log.info("车辆{}蓝牙钥匙查询请求", vin);
        BaseRestResponse<VinBluetoothsVo> response = null;
        try {
            response = msBluetoothService.getBluetoothByVin(vin);
            log.info("根据vin:{}查询车辆蓝牙钥匙信息接口返回:{}", vin, JSON.toJSONString(response));
            return response;
        } catch (Exception e) {
            log.error("根据vin:{}查询车辆蓝牙钥匙信息失败:{}", vin, JSON.toJSONString(e));
            return new BaseRestResponse<>("-1", e.getMessage());
        }
    }

//    @PostMapping("/logoutBluetoothByVinAndMobilePhone")
//    @ApiOperation(value = "根据vin和手机号注销蓝牙钥匙", httpMethod = "GET", response = BaseRestResponse.class)
//    public BaseRestResponse logoutBluetoothByVinAndMobilePhone(
//            @ApiParam(value = "车架号", required = true) @RequestParam String vin,
//            @ApiParam(value = "手机号", required = true) @RequestParam String mobilePhone) {
//        log.info("车辆{}蓝牙钥匙查询请求", vin);
//        BaseRestResponse<VinBluetoothsVo> response = null;
//        try {
//            response = msBluetoothService.getBluetoothByVin(vin);
//            log.info("根据vin:{}查询车辆蓝牙钥匙信息接口返回:{}", vin, JSON.toJSONString(response));
//            return response;
//        } catch (Exception e) {
//            return new BaseRestResponse<>("-1", e.getMessage());
//        }
//    }
}
